/**===============================================================================
 * This file for setting row background-color of table while mouse is on over. 
 * @author Created by this author
 * @date 2017-07-18
 * @param x
 * @param y 
 * =============================================================================== */
function onChange(x, y) {
  if (y == 0) {
	$('#' + x).css('background-color', 'rgba(0, 0, 255, .1)');  
  }	else {
	$('#' + x).css('background-color', '#fff');  
  }
}

/**====================================================================================
 * The two following functions for displaying picture while uploading picture file
 * @author this author
 * @date 2017-07-27 
 * @param file
 * ===================================================================================== */
function onFile(file) {
  var suffix = file.value.substring(file.value.lastIndexOf('.') + 1).toLowerCase();
  if (suffix != 'png' && suffix != 'jpg' && suffix != 'jpeg') {
	alert('Picture Format is required to be some kind from PNG, JPG, or JPEG.');
	return ;
  }
  var isMSIE = navigator.userAgent.match(/MSIE/) != null;
  var isMSIE6 = navigator.userAgent.match(/MSIE 6.0/) != null;
  if (isMSIE) {
	file.select();
	var realLocalPath = document.selection.createRange().text;
	var picture = document.getElementById('img');   
	if (isMSIE6) {
	  picture.src = realLocalPath;	
	} else {
	  picture.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod='image', src=\"" + realLocalPath + "\")"; 
	  picture.src = 'data.image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==';
	}
  } else {
	html5Reader(file);   
  }
}

function html5Reader(file) {
  var file = file.files[0];
  var reader = new FileReader();
  reader.readAsDataURL(file);
  reader.onload = function(e) {
	var picture = document.getElementById('img');
	picture.src = this.result;
  }
}

/**===============================================================================================
 * The two following functions for modifying order state.
 * @author this author
 * @date 2017-07-27
 * @param url
 * @param width
 * @param height
 * @returns {___anonymous2706_2708}
 * ================================================================================================ */
function openWindow(url, width, height) {
  var left = (screen.width - width) / 2;
  var top = (screen.height - height) / 2;
  var features = 'left = ' + left + ', top = ' + top + ', width = ' + width + ', height = ' + height + ', center = 1, scrollbars = 0, status = 0, directors = 0, channelmode = 0';
  var win = window.open(url, 'window', features);
  if (!win.opener) {
	win.opener = self;  
  }
  win.focus();
  return win;
}

function closeWindow() {
  if (window.opener) {
	window.opener.location.reload(true);
	window.close();
  }	
}
